//SQL管理工具
function BasicSql_main() {
    return {
        dClick: function (cmp, r) {
            BasicSql_form().view({
                entityId: r.get('id')
            });
        },
        id: 'BasicSql_main',
        xtype: 'jgrid',
        clazz: BasicSql,
        order: [],
        where: [],
        top: [{
            name: 'sqlKey',
            text: 'SQL键',
            op: 'like',
            xtype: "textfield"
        }, {
            name: 'sqlSentence',
            text: 'SQL描述',
            op: 'like',
            xtype: "textfield"
        }, $.search, '->', {
            key: 'A',
            iconCls: ion.add,
            text: '添加SQL',
            handler: function () {
                BasicSql_form().save({
                    grid: ['BasicSql_main']
                });
            }
        }, {
            key: 'E',
            iconCls: ion.edit,
            text: '修改SQL',
            handler: function () {
                BasicSql_form().edit({
                    grid: ['BasicSql_main']
                });
            }
        }, {
            key: 'D',
            iconCls: ion.del,
            text: '删除',
            handler: function () {
                $('BasicSql_main').deletes({
                    validate: []
                });
            }
        }],
        columns: [
            {
                text: "SQL键",
                width: 200,
                "name": "sqlKey"
            },
            {
                text: "SQL描述",
                width: 240,
                "name": "sqlMemo"
            },
            {
                text: "SQL语句",
                flex: 1,
                "name": "sqlSentence"
            }
        ]
    }
}

function BasicSql_form() {
    return $({
        xtype: 'jform',
        clazz: BasicSql,
        fieldsSize: 1,
        width: 400,
        hides: [],
        validate: [['sqlKey = ?', "sqlKey", "SQL键已存在"]],
        fields: [
            {
                req: true,
                "name": "sqlKey"
            },
            {
                "name": "sqlMemo",
                xtype: "textarea"
            }, {
                req: true,
                xtype: "textarea",
                "name": "sqlSentence",
                height: 200
            }
        ]
    })
}